package cn.fj.data.service.impl;

import cn.fj.basic.util.PageList;
import cn.fj.data.domain.Dictionary;
import cn.fj.data.mapper.DictionaryMapper;
import cn.fj.data.query.DictionaryQuery;
import cn.fj.data.service.IDictionaryService;
import cn.fj.org.domain.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DictionaryServiceimpl implements IDictionaryService

{
    @Autowired
    private  DictionaryMapper dictionarymapper;
    @Override
    public void add(Dictionary dictionary) {
        dictionarymapper.add(dictionary);//添加数据的时候，获取主键自增
        //调用update
        modify(dictionary);

    }

    @Override
    public void delete(long id) {
        dictionarymapper.delete(id);


    }

    @Override
    /*修改*/
    public void modify(Dictionary dictionary) {
        dictionarymapper.modify(dictionary);


    }


    @Override
    public List<Dictionary> queryAll() {
        List<Dictionary> dictionaries = dictionarymapper.queryAll();
        return dictionaries;
    }

    @Override
    public Dictionary queryOne(Long id ) {
        Dictionary dictionary = dictionarymapper.queryOne();
        return dictionary;
    }


    @Override
    public PageList<Dictionary> queryData(DictionaryQuery dictionaryquery) {
        Integer count = dictionarymapper.count(dictionaryquery);
        System.out.println(count);
        //查询每页数据
        List<Dictionary> list = dictionarymapper.queryData(dictionaryquery);
        PageList<Dictionary> PageList = new PageList<Dictionary>(count, list);
        return  PageList;
    }

    @Override
    public void allDelete(List<Long> ids) {
        dictionarymapper.allDelete(ids);

    }

    @Override
    public List<Department> depTree() {
        return null;
    }

    @Override
    public void delete1(Long id) {
        dictionarymapper.delete1(id);
    }

    @Override
    public void allDelete1(List<Long> ids) {
        dictionarymapper.allDelete1(ids);
    }
}
